<?php
include_once "xAP-functions/webincludes.php";
echo webpageheader();


$id=intval($_GET["id"]);  //trigger id
$now=date("Y-m-d H:i:s");


$sql="select TriggerID,ProgName,ProgDesc,Delay,ChannelName 
from xAP_TV_Trigger where TriggerID=".$id."
";
$results=dbquery($sql);
$row=$results[0];

$sql="select ChannelName,ChannelAlias from xAP_TV_Channel order by channelorder";
$channels=dbquery($sql);






//display
?>
<form method='POST' action='config_trigger_save.php'>
<input type='hidden' name='id' value=<?=$id?>>
<table>


<tr>
	<TD class='normaltext'>Program Name</td>
	<TD class='normaltext'> </td>
	<TD class='normaltext'><input name='name' size=30 value="<?=$row["ProgName"]?>"></td>
</tr>
<tr>
	<TD class='normaltext'>Program Description</td>
	<TD class='normaltext'> </td>
	<TD class='normaltext'><input name='desc' size=30 value="<?=$row["ProgDesc"]?>"></td>
</tr>
<tr>
	<TD class='normaltext'>Channel</td>
	<TD class='normaltext'> </td>
	<TD class='normaltext'><select name='channel'><option value=''>Any
	<?php
	foreach($channels as $c){
		if ($c["ChannelName"]==$row["ChannelName"]){
			echo "<option value=\"".$c["ChannelName"]."\" SELECTED>".$c["ChannelAlias"];
		}else{
			echo "<option value=\"".$c["ChannelName"]."\">".$c["ChannelAlias"];
		}
	}
	?>
	</select></td>
</tr>
<tr>
	<TD class='normaltext'>Delay</td>
	<TD class='normaltext'> </td>
	<TD class='normaltext'><select name='delay'><option><?=intval($row["Delay"])?>
	<option>1<option>2<option>5<option>10<option>15
	</select></td>
</tr>	
<? if($id>0):?>
<tr>
	<TD class='normaltext'>Delete</td>
	<TD class='normaltext'> </td>
	<TD class='normaltext'><input type='checkbox' name='delete' value=1></td>
</tr>
<? endif;?>
<tr><td colspan=3 class='normaltext'><input type='submit' value='Update'></td></tr>
</table>
</form>
<?php
echo webpagefooter();
?>